
var WebSocketServer = require('ws').Server
var wss = null
var _ws = null
module.exports = app => {
    return class User extends app.Service {
        * set_websocket() {
            wss = new WebSocketServer({
                port: 8077,//监听接口  

            });
            wss.on('connection', function (ws) {
                console.log("服务器创建链接")
                _ws = ws
                console.log("服务器链接成功")
            })
            console.log(123)

        }
        * send_websocket(msg) {
            
            _ws.send(msg)
            console.log('send事件执行成功')
        }

    }
};